package y23.Nov;

import java.io.*;
import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) throws IOException {
        Reader reader = new FileReader("hello.txt");
        StringBuffer str1 = new StringBuffer();
        StringBuffer str2 = new StringBuffer();

        //无参read:一次读取一个字符，读取完毕·返回-1；
        /*while (true){
            int c= reader.read();
            if(c==-1){
                break;
            }
            str1.append((char)c);
        }
        System.out.println(str1);*/


        //read(char[] cubf):一次读取多个字符，读取完毕返回-1
        try{
            while(true){
                char[] cubf = new char[3];
                int n = reader.read(cubf);
                if (n == -1){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    str2.append(cubf[i]);
                }
            }
            System.out.println(str2);
        }finally {
            reader.close();
        }

    }
}

